#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/8 20:00
# @Author  : jeff
# @FileName: role_model
from sqlalchemy.sql import expression
from src.model.base_model import BaseModel, db


class Role(BaseModel):
    __tablename__ = 'roles'

    role_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    role_name = db.Column(db.String(255), nullable=False)
    access_route = db.Column(db.String(1024))
    action = db.Column(db.String(255))
    is_deleted = db.Column(db.Boolean, server_default=expression.false())

    @classmethod
    def query_by_id(cls, role_id):
        return cls.query.filter_by(role_id=role_id).all()
